<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<h2 style="text-align: center;"> 学生信息添加或者更新页面 </h2>
<div style="width: 500px; margin: 0 auto;">
    <form action="addInfo" method="post" enctype="multipart/form-data">
        @csrf
        <input type="hidden" name="id" value="{{$student?$student->id:'0'}}">
        姓名：<input style="margin:10px 0;" type="text" name="name" value="{{$student?$student->name:''}}"><br>
        性别：<input style="margin:10px 0;" type="radio" name="gender"
                  value="1" {{$student?($student->gender==1?'checked':''):''}}>男
        <input style="margin:10px 0;" type="radio" name="gender"
               value="2" {{$student?($student->gender==2?'checked':''):''}}>女<br>
        头像：<input style="margin:10px 0;" type="file" name="headimg"><br>
        @if($student)
            <img style="width: 40px;height: 40px" src="{{$student?$student->img:''}}" alt=""><br>
        @endif
        手机号：<input style="margin:10px 0;" type="text" name="phone" value="{{$student?$student->phone:''}}"><br>
        兴趣：<input style="margin:10px 0;" type="checkbox" name="hobby[]" {{$student?(in_array(1,$student->hobby)?'checked':''):''}} value="1">读书
        <input type="checkbox" name="hobby[]" value="2" {{$student?(in_array(2,$student->hobby)?'checked':''):''}} >旅游
        <input type="checkbox" name="hobby[]" value="3" {{$student?(in_array(3,$student->hobby)?'checked':''):''}} >编程
        <input type="checkbox" name="hobby[]" value="4" {{$student?(in_array(4,$student->hobby)?'checked':''):''}} >英语<br>
        <button style="margin: 10px 0 10px 100px;" type="submit"> 提交</button>
    </form>
</div>
</body>
</html>
